package cn.itcast.ks.controller.v1;

import cn.itcast.ks.common.ResponseResult;
import cn.itcast.ks.pojo.dtos.AssignmentDto;
import cn.itcast.ks.pojo.dtos.NotWorkDto;
import cn.itcast.ks.pojo.dtos.ShowWorkDto;
import cn.itcast.ks.pojo.dtos.WorkDto;
import cn.itcast.ks.service.IAssignmentService;
import cn.itcast.ks.service.UserStudentAssignmentService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author mwj
 * @date 2021/12/5
 * @TIME:16:59
 */
@RestController
@RequestMapping("/v1/work")
public class WorkController {
    @Autowired
    private UserStudentAssignmentService userStudentAssignmentService;
    @Autowired
    private IAssignmentService assignmentService;
    //展示学生作业列表
    @PostMapping("/showWorks")
    public ResponseResult showWorks(@RequestBody ShowWorkDto showWorkDto){

        return userStudentAssignmentService.showWorks(showWorkDto);

    }

    //发布作业
    @PostMapping("/publishWork")
    public ResponseResult publishWork(@RequestBody WorkDto workDto){

        return assignmentService.publishWork(workDto);
    }


    //查询时间段未提交作业的学生以及次数
    @PostMapping("/findNotWorkByTime")
    public ResponseResult findNotWorkByTime(@RequestBody NotWorkDto notWorkDto){
        return userStudentAssignmentService.findNotWorkByTime(notWorkDto);
    }

    //查询作业列表（学生接口）
    @PostMapping("/findStudentWork")
    public ResponseResult findStudentWork(@RequestBody ShowWorkDto showWorkDto){

        return userStudentAssignmentService.findStudentWork(showWorkDto);
    }


    //学生提交作业（学生接口）
    @GetMapping("/submitWork/{workId}/{status}")
    public ResponseResult submitWork(@PathVariable("workId") Integer workId,@PathVariable("status") Integer status){

        //todo 是否需要考虑如果已经提交
        return userStudentAssignmentService.submitWork(workId,status);



    }

}
